package com.ssy.jt808.protocol.t808;

import com.ssy.jt808.protocol.basics.JTMessage;
import com.ssy.jt808.protocol.commons.Bit;
import com.ssy.jt808.protocol.commons.JT808;
import com.ssy.jt808.protocol.commons.transform.AttributeConverter;
import com.ssy.jt808.protocol.commons.transform.AttributeConverterYue;
import io.github.yezhihao.protostar.annotation.Field;
import io.github.yezhihao.protostar.annotation.Message;
import io.netty.buffer.ByteBuf;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @author yezhihao
 * https://gitee.com/yezhihao/jt808-server
 */
@Data
@Message(JT808.位置信息汇报)
public class T0200 extends JTMessage{

  /**
   * 使用 Bit.isTrue判断报警和状态标志位
   *
   * @see Bit
   */
  @Field(length=4, desc="报警标志")
  private int                 alarmBits;
  @Field(length=4, desc="状态")
  private int                 statusBits;
  @Field(length=4, desc="纬度")
  private int                 latitude;
  @Field(length=4, desc="经度")
  private int                 longitude;
  @Field(length=2, desc="高程(米)")
  private int                 altitude;
  @Field(length=2, desc="速度(1/10公里每小时)")
  private int                 speed;
  @Field(length=2, desc="方向")
  private int                 direction;
  @Field(length=6, charset="BCD", desc="时间(YYMMDDHHMMSS)")
  private LocalDateTime       deviceTime;
  @Field(converter=AttributeConverter.class, desc="位置附加信息", version={ -1, 0 })
  @Field(converter=AttributeConverterYue.class, desc="位置附加信息(粤标)", version=1)
  private Map<Integer,Object> attributes;

  public T0200(){
  }

  @Override
  public void setPayload( ByteBuf payload ){
    super.setPayload(payload.copy());
  }
}